home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4679 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, argv, strcmp()
  5. Date: Tue, 06 Feb 96 14:01:51 GMT
  6. Organization: none
  7. Message-ID: <823615311snz@genesis.demon.co.uk>
  8. References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu> <fcusack-0302961645280001@mudskipper.cac.psu.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <fcusack-0302961645280001@mudskipper.cac.psu.edu>
  15.            fcusack@tdx.org "frank." writes:
  16.  
  17. >Yes, the && test would never pass, but the || test is bad also. The ||
  18. >will pass if you pass "-d" or "-e". So then you will call Usage()
  19. >incorrectly. The test should be:
  20. >
  21. >   if (!(!strcmp(argv[1], "-d") || !strcmp(argv[1], "-e"))) {
  22. >      Usage();
  23. >   }
  24.  
  25. That is correct but it is pretty horrible to read. I prefer something like:
  26.  
  27.     if (strcmp(argv[1], "-d") != 0 && strcmp(argv[1], "-e") != 0) {
  28.     ...
  29.  
  30. -- 
  31. -----------------------------------------
  32. Lawrence Kirby | fred@genesis.demon.co.uk
  33. Wilts, England | 70734.126@compuserve.com
  34. -----------------------------------------
  35.